﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Configuration;
using BloomFilter.String;
using System.IO;
using BloomFilter;

namespace BloomFilterTester
{
    class FilterParam : IBloomFilterData<string>
    {
        public FilterParam(string key, string val)
        {
            keyName = key;
            this.val = val;
        }

        private string keyName;

        public string KeyName
        {
            get
            {
                return keyName;
            }
            set
            {
                keyName = value;
            }
        }

        private string val;

        public string Value
        {
            get
            {
                return val;
            }
            set
            {
                val = value;
            }
        }

        public bool IsValid()
        {
            return true;
        }
    }


    class Program
    {

        static void Main(string[] args)
        {
            StringBloomFilterManager myManager = new StringBloomFilterManager(1024 * 1024 * 8, 3, @"E:\filtertest");

            string myerror = string.Empty;

            if (!myManager.Init(out myerror, false))
            {
                Console.WriteLine(myerror);
            }
            else
            {
                Console.WriteLine("初始化成功。");
            }

            //(?<=://)[a-zA-Z\.0-9]+(?=\/)

            Console.WriteLine("7a0c2f82c0157f1a0c8ab53696222305");
            if (myManager.Add(new FilterParam("www.163.com", "7a0c2f82c0157f1a0c8ab53696222305")))
            {
                Console.WriteLine("添加成功。 7a0c2f82c0157f1a0c8ab53696222305");
            }
            else
            {
                Console.WriteLine("添加失败。");
            }


            myManager.SaveFilters();

            if (myManager.IsHave(new FilterParam("www.163.com", "7a0c2f82c0157f1a0c8ab53696222305")))
            {
                Console.WriteLine("已经含有。");
            }
            else
            {
                Console.WriteLine("尚未含有。");
            }


            Console.WriteLine("658de467aa26b55a830d4164bfb37cc8");
            if (myManager.IsHave(new FilterParam("www.163.com", "658de467aa26b55a830d4164bfb37cc8")))
            {
                Console.WriteLine("已经含有。");
            }
            else
            {
                Console.WriteLine("尚未含有。");
            }


            
            Console.ReadKey();
        }


    }
}
